package com.geticsen.leetcode;

import java.util.*;

public class Solution_448 {
    public List<Integer> findDisappearedNumbers(int[] nums) {
        int len = nums.length;
        List<Integer> result = new ArrayList<>();
        //将出现的排除
        for (int num : nums) {
            nums[(num - 1) % len] += len;
        }
        //
        for (int i = 0; i < len; i++) {
            if (nums[i] <= len) {
                result.add(i + 1);
            }
        }
        return result;
    }

    public List<Integer> findDisappearedNumbers1(int[] nums) {
        List<Integer> result = new ArrayList<>();
        if (nums == null || nums.length == 0) {
            return result;
        }
        Set<Integer> integerSet = new HashSet<>();
        for (int num : nums) {
            integerSet.add(num);
        }
        for (int i = 1; i <= nums.length; i++) {
            if (!integerSet.contains(i)) {
                result.add(i);
            }
        }
        return result;
    }
}
